﻿namespace EFMLEditor.Internal
{
    using System.Collections.Generic;

    public class Global
    {
        private static readonly Dictionary<string, object> items = new Dictionary<string, object>();

        public static void Add<T>() where T : new()
        {
            Add(typeof(T).FullName, new T());
        }

        public static T Get<T>()
        {
            return (T)items[typeof(T).FullName];
        }

        public static void Add(string k, object v)
        {
            if (!items.ContainsKey(k))
            {
                items.Add(k, v);
            } 
            else
            {
                items[k] = v;
            }
        }

        public static void Remove(string k)
        {
            items.Remove(k);
        }

        public static T Get<T>(string k)
        {
            return (T)items[k];
        }

        public static string Get(string k)
        {
            if (items.ContainsKey(k))
            {
                return (string)items[k];
            }
            return "";
        }
    }
}